package com.blockmeta.bbs.immodule.corebean;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.blockmeta.bbs.businesslibrary.business.BaseManager;
import com.blockmeta.bbs.businesslibrary.pojo.MessageParam;
import com.blockmeta.bbs.immodule.dao.ChatMessage;

import java.util.List;


/**
 * @author author
 * IM 所有事件发送类！
 */
public abstract class IMMetaBase extends BaseManager {


    public enum IMMsgType {
        SENDED, SENDING, RECIEVE, ERROR
    }


    public static final int BEGIN_UPLOAD = 1;
    public static final int COMPLETE_UPLOAD = 2;
    public static final int UPLOADING = 3;
    public static final int ERROR_UPLOAD = 4;

    public static final int BEGIN_DOWNLOAD = 1;
    public static final int COMPLETE_DOWNLOAD = 2;
    public static final int DOWNLOADING = 3;
    public static final int ERROR_DOWNLOAD = 4;

    //查找数量
    protected static final int m_nQueryCount = 100;
    protected int m_nUnreadCount = 0;

    public abstract void getMessageList();

    public abstract void getChatGroupList();

    public abstract void getFriendList();

    public abstract MsgWorker getWorker();

    public abstract void onCreate();

    public abstract boolean isBindService();

    public abstract void onStopServer();

    public abstract void sendChatMessage(ChatMessage message);

    public abstract void getTodoList(int i);


    public abstract void handMessageIntent(Intent intent);

    public abstract ChatMessage sendMessage(MessageParam messageParam);

    public abstract void sendNormalMessage(int msgType, long toId, String pText, MessageSendCallBack callBack);

    //适用于单选发送
    public abstract void sendImageMessage(int msgType, long toId, String pText);

    public abstract void sendCustomMessage(int msgType, long toId, String pText, int subType, MessageSendCallBack callBack);

    public abstract void sendHongbao(int msgType, long toId, long messageId, String pText, MessageSendCallBack callBack);

    public abstract void sendFileMessage(int msgType, long toId, String pText);

    public abstract void uploadImImage(Context mContext, String circleImageFileUrl, IFileHttpService.IMFileUploadCallBack imFileUploadCallBack);

    public abstract void sendRemoteFileMessage(int msgType, long toId, String fileName, String pText, int size, MessageSendCallBack callBack);

    public abstract int getFileProgress(String filePath);

    public abstract void downLoadFile(final ChatMessage message);

    //发送失败之后的二次发送
    public abstract void resendMessage(ChatMessage chatMessage, MessageSendCallBack callBack);

    public interface IMsgEventListener {
        void onPacket(String type, Bundle objPacket);
    }

    public static class Event_IMSearchMessageList {
        public String m_query;
        public List<ChatMessage> m_list;
        public boolean m_bFinish;

        public Event_IMSearchMessageList(String query, List<ChatMessage> pList, boolean finish) {
            m_query = query;
            m_list = pList;
            m_bFinish = finish;
        }
    }

    //消息列表
    public static class Event_IMMessageList {
        public List<ChatMessage> m_list;
        public boolean m_bFinish;
        public QueryDirectionEnum m_Direction;

        public Event_IMMessageList() {

        }

    }

    //消息
    public static class Event_IMMessage {
        public ChatMessage m_message;
        public IMMsgType m_type;

        public Event_IMMessage(ChatMessage pMessage, IMMsgType pType) {
            m_message = pMessage;
            m_type = pType;
        }
    }


    //消息
    public static class Event_SendIMMessageUnCallback {
        public ChatMessage m_message;
        public IMMsgType m_type;

        public Event_SendIMMessageUnCallback(ChatMessage pMessage, IMMsgType pType) {
            m_message = pMessage;
            m_type = pType;
        }
    }

    /**
     * 发送消息成功的消息回执！
     */
    public static class Event_ReceiptMessage {
        public String uuid;
        public int status;
        public IMMsgType msgType;

        public Event_ReceiptMessage(String uuid, int status, IMMsgType msgType) {
            this.uuid = uuid;
            this.status = status;
            this.msgType = msgType;
        }
    }

    //文件发送事件
    public static class Event_FileUploadMessage {
        public int status;
        public int progress;
        public ChatMessage message;


        public Event_FileUploadMessage(int status, int progress, ChatMessage message) {
            this.status = status;
            this.progress = progress;
            this.message = message;
        }

        public Event_FileUploadMessage(int status, ChatMessage message) {
            this.status = status;
            this.message = message;
        }
    }

    //文件发送事件
    public static class Event_FileDownLoadMessage {
        public int status;
        public int progress;
        public ChatMessage message;


        public Event_FileDownLoadMessage(int status, int progress, ChatMessage message) {
            this.status = status;
            this.progress = progress;
            this.message = message;
        }

        public Event_FileDownLoadMessage(int status, ChatMessage message) {
            this.status = status;
            this.message = message;
        }
    }

    /**
     * 获取到好友列表
     */
    public static class Event_FriendList {
    }

    /**
     * 获取到圈子列表
     */
    public static class Event_GroupList {

    }

    /**
     * 有好友同意加入，需要刷新好友列表
     */
    public static class Event_AddFriends {

    }

    public static class Event_DeleteFriends {

    }
    /**
     * 有圈子同意加入，需要刷新圈子列表
     */
    public static class Event_AddCircles {

    }

    public static class Event_EditCircles {
        public long circleId;

        public Event_EditCircles(long id) {
            this.circleId = id;
        }
    }

    public static class Event_DeleteCircles {

    }
    /**
     * 有好友请求，需要刷新好友加入数字
     */
    public static class Event_FriendRequestAdd {

    }

    /**
     * 有可能临时好友有增加，因为客户端目前不知道这个事件
     */
    public static class Event_MayBeTempTalkAdd{

    }

    /**
     * 屏蔽好友
     */
    public static class EventShieldFriend{
        public boolean isShield;

        public EventShieldFriend() {
        }

        public EventShieldFriend(boolean isShield) {
            this.isShield = isShield;
        }
    }

    public static class Event_ReadAllMsgFromOne{
        public long toUserId;
        public int type;

        public Event_ReadAllMsgFromOne(long toUserId, int type) {
            this.toUserId = toUserId;
            this.type = type;
        }
    }

    public static class Event_Delete_Message {
        public ChatMessage m_ImMessage;
        public boolean isSuccess;

        public Event_Delete_Message(ChatMessage p_ImMessage, boolean isSuccess) {
            this.m_ImMessage = p_ImMessage;
            this.isSuccess = isSuccess;
        }
    }


    public static class Event_Comment_Data {
        public int eventCode;
        public long circleId;

        public Event_Comment_Data(int eventCode, long mCircleId) {
            this.eventCode = eventCode;
            this.circleId = mCircleId;
        }
    }

    public static class Event_MessageTimeOut {

        public String uuid;

        public Event_MessageTimeOut(String uuid) {
            this.uuid = uuid;
        }
    }

    public static class Event_KickOffMember {
        public long circleId;
        public int count;

        public Event_KickOffMember(long circleId, int count) {
            this.circleId = circleId;
            this.count = count;
        }
    }

    public static class Event_AddMemberToCircle {
        public long groupId;

        public Event_AddMemberToCircle(long groupId) {
            this.groupId = groupId;
        }
    }

    public static class Event_MyCircleRemarkNameChange {
        public long circleId;

        public Event_MyCircleRemarkNameChange(long circleId) {
            this.circleId = circleId;
        }
    }
    public static class Event_CircleStickUpdate {
        public long circleId;
        public boolean isChecked;

        public Event_CircleStickUpdate(long mCircleId, boolean isChecked) {
            this.circleId = mCircleId;
            this.isChecked = isChecked;
        }
    }

    public static class Event_SendIMMessage {
        public ChatMessage chatMessage;

        public Event_SendIMMessage(ChatMessage chatMessage) {
            this.chatMessage = chatMessage;
        }
    }

    public static class Event_AddCircleNotice {
        public long mCircleId;
        public Event_AddCircleNotice(long circleId) {
            this.mCircleId = circleId;
        }
    }

    public enum QueryDirectionEnum {
        QUERY_OLD,
        QUERY_NEW;

        private QueryDirectionEnum() {
        }
    }

    public interface MessageSendCallBack {
        void fail(String msg);

        void success(ChatMessage chatMessage);
    }


}
